﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RegionSplittor.Utils;

namespace HYLightingEquipmentLay.CommonUtils
{
	public class FloorUtils
	{
		public static bool GetOneFloorBylstElement(List<Element> lstEle, out Floor floor)
		{
			bool result = false;
			floor = null;
			if (lstEle.Count == 0)
			{
				return result;
			}
			foreach (Element element in lstEle)
			{
				if (element is Floor)
				{
					floor = (element as Floor);
					return true;
				}
			}
			return result;
		}

		public static double GetFloorBtmHeight(Autodesk.Revit.DB.Document floorDoc, List<CurveLoop> lstLoop, XYZ extrDir, double dExtrDist)
		{
			double result = 0.0;
			ElementMulticategoryFilter categoryFilter = new ElementMulticategoryFilter(new List<BuiltInCategory>
			{
				(Autodesk.Revit.DB.BuiltInCategory)(-2000032)
			});
			Floor ele;
			if (!FloorUtils.GetOneFloorBylstElement(ElementSelector.GetSolidIntersectElement(floorDoc, lstLoop, extrDir, dExtrDist, categoryFilter), out ele))
			{
				return result;
			}
			return BeamOperator.GetEleParamDoubleValue(ele, "底部高程");
		}
	}
}
